package com.example.baiduapi.constant;


/**
 * 通用常量信息
 *
 * @author mise
 */
public class Constants
{
    /**
     * UTF-8 字符集
     */
    public static final String UTF8 = "UTF-8";

    /**
     * GBK 字符集
     */
    public static final String GBK = "GBK";

    /**
     * http请求
     */
    public static final String HTTP = "http://";

    /**
     * https请求
     */
    public static final String HTTPS = "https://";

    /**
     * 通用成功标识
     */
    public static final String SUCCESS = "0";

    /**
     * 通用失败标识
     */
    public static final String FAIL = "1";

    /**
     * 登录成功
     */
    public static final String LOGIN_SUCCESS = "Success";

    /**
     * 注销
     */
    public static final String LOGOUT = "Logout";

    /**
     * 注册
     */
    public static final String REGISTER = "Register";

    /**
     * 登录失败
     */
    public static final String LOGIN_FAIL = "Error";

    /**
     * 验证码 redis key
     */
    public static final String CAPTCHA_CODE_KEY = "captcha_codes:";

    /**
     * 登录用户 redis key
     */
    public static final String LOGIN_TOKEN_KEY = "login_tokens:";

    /**
     * 防重提交 redis key
     */
    public static final String REPEAT_SUBMIT_KEY = "repeat_submit:";

    /**
     * 限流 redis key
     */
    public static final String RATE_LIMIT_KEY = "rate_limit:";

    /**
     * 验证码有效期（分钟）
     */
    public static final Integer CAPTCHA_EXPIRATION = 2;

    /**
     * 令牌
     */
    public static final String TOKEN = "token";

    /**
     * 令牌前缀
     */
    public static final String TOKEN_PREFIX = "Bearer ";

    /**
     * 令牌前缀
     */
    public static final String LOGIN_USER_KEY = "login_user_key";

    /**
     * 用户ID
     */
    public static final String JWT_USERID = "userid";

    /**
     * 用户头像
     */
    public static final String JWT_AVATAR = "avatar";

    /**
     * 创建时间
     */
    public static final String JWT_CREATED = "created";

    /**
     * 用户权限
     */
    public static final String JWT_AUTHORITIES = "authorities";

    /**
     * 参数管理 cache key
     */
    public static final String SYS_CONFIG_KEY = "sys_config:";

    /**
     * 字典管理 cache key
     */
    public static final String SYS_DICT_KEY = "sys_dict:";

    /**
     * 资源映射路径 前缀
     */
    public static final String RESOURCE_PREFIX = "/profile";

    /**
     * RMI 远程方法调用
     */
    public static final String LOOKUP_RMI = "rmi://";

    /**
     * LDAP 远程方法调用
     */
    public static final String LOOKUP_LDAP = "ldap://";

    /**
     * 节点类型
     */
    public enum NodeType{
        CJ(0,"创建"),TJ(1,"提交"),SP(2,"审批"),GD(3,"归档");
        private Integer key;
        private String val;

        NodeType(Integer key, String val) {
            this.key = key;
            this.val = val;
        }

        public Integer getKey() {
            return key;
        }

        public String getVal() {
            return val;
        }

        /**
         * 根据key获取当前的枚举对象
         *
         * @param key
         * @return CouponStatus
         */
        public static NodeType getStatus(Integer key) {
            if (key == null) {
                return null;
            }
            for (NodeType status : values()) {
                if (status.getKey().equals(key)) {
                    return status;
                }
            }
            return null;
        }
    }

    /**
     * 节点按钮类型
     */
    public enum NodeBtn{
        SAVE(1,"保存"),SUBMIT(2,"提交"),FORWORD(3,"转办"),RETURN(4,"退回"),OK(5,"批准");
        private Integer key;
        private String val;

        NodeBtn(Integer key, String val) {
            this.key = key;
            this.val = val;
        }

        public Integer getKey() {
            return key;
        }

        public String getVal() {
            return val;
        }

        /**
         * 根据key获取当前的枚举对象
         *
         * @param key
         * @return CouponStatus
         */
        public static NodeBtn getStatus(Integer key) {
            if (key == null) {
                return null;
            }
            for (NodeBtn status : values()) {
                if (status.getKey().equals(key)) {
                    return status;
                }
            }
            return null;
        }
    }

    /**
     * 文档状态
     */
    public enum DocStatus {
        ZC(1, "正常"), SX(2, "失效"), SC(3, "删除"), GD(4, "归档"), ZF(5, "作废"),SXZF(6, "作废"), GDZF(7, "作废");
        private Integer key;
        private String val;

        DocStatus(Integer key, String val) {
            this.key = key;
            this.val = val;
        }

        public Integer getKey() {
            return key;
        }

        public String getVal() {
            return val;
        }

        /**
         * 根据key获取当前的枚举对象
         *
         * @param key
         * @return CouponStatus
         */
        public static DocStatus getStatus(Integer key) {
            if (key == null) {
                return null;
            }
            for (DocStatus status : values()) {
                if (status.getKey().equals(key)) {
                    return status;
                }
            }
            return null;
        }
    }

    /**
     * 文档操作类型
     */
    public enum DocOpaType {
        VIEW(1,"查看"),EDIT(2,"编辑"),DELETE(4, "删除"),KEEP(5, "归档"),INVALID(6, "失效"),CANCEL(7, "作废"),CONTROL(3, "完全控制");
        private Integer key;
        private String val;

        DocOpaType(Integer key, String val) {
            this.key = key;
            this.val = val;
        }

        public Integer getKey() {
            return key;
        }

        public String getVal() {
            return val;
        }

        /**
         * 根据key获取当前的枚举对象
         *
         * @param key
         * @return CouponStatus
         */
        public static DocOpaType getStatus(Integer key) {
            if (key == null) {
                return null;
            }
            for (DocOpaType status : values()) {
                if (status.getKey().equals(key)) {
                    return status;
                }
            }
            return null;
        }
    }

}
